package com.example.lanqiaodemo1.JavaTest6;

import java.util.*;

public class ListDemo {
    public static void main(String[] args) {
        ArrayList list = new ArrayList<Student>();
        list.add(new Student("张三", "男", 20));
        list.add(new Student("李四", "男", 22));
        ListIterator it = list.listIterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }


        List<String> list2 = new ArrayList<String>();
        list2.add("aaa");
        list2.add("bbb");
        ListIterator it2 = list2.listIterator();
        while (it2.hasNext()) {
            System.out.println(it2.next());
        }


        Map<String, Student> map = new HashMap<String, Student>();
        map.put("s1", new Student("王五", "男", 23));
        map.put("s2", new Student("王六", "男", 24));
        Set entrySet = map.entrySet();
        Iterator it3 = entrySet.iterator();
        while (it3.hasNext()) {
            System.out.println(it3.next());
        }

        Set set = new HashSet<Student>();
        set.add(new Student("张三", "男", 20));
        set.add(new Student("李四", "男", 22));
        Iterator it4 = set.iterator();
        while (it4.hasNext()) {
            System.out.println(it4.next());
        }


        List<Student> list3 = new ArrayList<Student>();
        list3.add(new Student("张三", "男", 22));
        list3.add(new Student("李四", "男", 20));
        list3.add(new Student("王五", "男", 21));
        Collections.sort(list3);
        for (Student s : list3) {
            System.out.println(s);
        }

    }

}